package org.example._06_filter;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;


public class Producer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer("rocketmq-producer");
        defaultMQProducer.setNamesrvAddr("127.0.0.1:9876");
        defaultMQProducer.start();
        Message message = new Message(
                "05-filter",//第一个参数  topic  主题
                "TagA",//生产者只支持贴一个标签,但是消费者可以获取多个标签
                "hello,rocketmq".getBytes()//第二个参数 byte[] 新消息内容
        );
        message.putUserProperty("age","16");
        SendResult sendResult = defaultMQProducer.send(message);
        System.out.println(sendResult.getMsgId());//没输出表示失败了
        defaultMQProducer.shutdown();
    }
}